import React, { useEffect, useRef } from 'react'

export default function App() {
  const inputRef = useRef(null)

  useEffect(() => {
    inputRef.current.focus()
  }, [])
  
  return (
    <div>
      <h1>自动获取input的焦点</h1>
      <input type="text" ref={inputRef} />
    </div>
  )
}
